from django import http
from django.http import  HttpResponse
from django.shortcuts import render
from django.views import View
from django.utils.decorators import method_decorator

def my_decorator(func):
    def wrapper(request, *args, **kwargs):
        print('---添加装饰器---{}'.format(request.method))
        return func(request, *args, **kwargs)
    return wrapper


class LoginView(View):
    def get(self, request):
        return HttpResponse('这里假装返回Login页面')

    def post(self, request):
        return HttpResponse('这里假装实现Login----------逻辑')

    @method_decorator(my_decorator)
    def put(self, request):
        return HttpResponse('put是修改功能')
    @method_decorator(my_decorator)
    def delete(self, request):
        return HttpResponse('delete是删除功能')

def index(request):
    return http.HttpResponse('code register!!!')

def login(request):
    if request.method == 'GET':
        return HttpResponse('这里是假装返回Login页面')

    else:
        return HttpResponse('这里假装实现Login---------逻辑')